﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

using AMPLibrary.Collections;

namespace MediaLibrary.Controls
{
    /// <summary>
    /// Interaction logic for ExclusionListPage.xaml
    /// </summary>
    public partial class ExclusionListPage : Page
    {
        public ExclusionListPage()
        {
            InitializeComponent();
            BindContent();
        }

        /// <summary>
        /// 
        /// </summary>
        private void BindContent()
        {
            ExcludedMediaCollection excludedMediaCollection = ExcludedMediaCollection.GetExcludedMediaCollection();
            this.excludedMediaListBox.ItemsSource = excludedMediaCollection;
            this.excludedMediaListBox.Items.Refresh();
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void excludedMediaListBox_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.Delete)
            {
                ExcludedMediaCollection excludedMediaCollection = ExcludedMediaCollection.GetExcludedMediaCollection();

                foreach (string item in excludedMediaListBox.SelectedItems)
                    excludedMediaCollection.RemoveItem(item);

                BindContent();
            }
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void excludedMediaListBox_Click(object sender, RoutedEventArgs e)
        {
            ExcludedMediaCollection excludedMediaCollection = ExcludedMediaCollection.GetExcludedMediaCollection();

            foreach (string item in excludedMediaListBox.SelectedItems)
                excludedMediaCollection.RemoveExcludedItem(item);

            BindContent();
        }
    }
}
